<template>
  <div class="news">
    <h3>最新新闻</h3>
    <div class="news-list">
      <div class="news-item" v-for="(item, index) in newsList" :key="index">
        <div class="news-date">{{ item.date }}</div>
        <div class="news-content">
          <h4>{{ item.title }}</h4>
          <p>{{ item.summary }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup name="News">
import { ref } from 'vue'

const newsList = ref([
  {
    date: '2024-01-15',
    title: 'Vue3 3.4版本发布',
    summary: 'Vue3发布了最新的3.4版本，带来了更好的性能和开发体验。'
  },
  {
    date: '2024-01-10',
    title: 'TypeScript 5.3更新',
    summary: 'TypeScript发布了5.3版本，新增了多项功能和性能优化。'
  },
  {
    date: '2024-01-05',
    title: '前端开发趋势',
    summary: '2024年前端开发的主要趋势包括AI辅助编程、WebAssembly等。'
  }
])
</script>

<style scoped>
.news {
  padding: 20px;
}

h3 {
  color: #2c3e50;
  text-align: center;
  margin-bottom: 30px;
  font-size: 2em;
}

.news-list {
  max-width: 800px;
  margin: 0 auto;
}

.news-item {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  display: flex;
  gap: 20px;
  transition: transform 0.3s ease;
}

.news-item:hover {
  transform: translateX(5px);
}

.news-date {
  background: #667eea;
  color: white;
  padding: 10px 15px;
  border-radius: 5px;
  font-weight: bold;
  min-width: 100px;
  text-align: center;
  align-self: flex-start;
}

.news-content h4 {
  color: #2c3e50;
  margin: 0 0 10px 0;
  font-size: 1.2em;
}

.news-content p {
  color: #666;
  margin: 0;
  line-height: 1.6;
}
</style>
